<?php


require 'db_conn.php';
//获取地址栏上送过来的ID
$bbsid=isset($_GET['id'])?$_GET['id']:0;
if(!$_POST){
$sql="select * from t_message where id='$bbsid'";
//得到的是结果集，不能直接读取
$rs=$db->query($sql);
$row=$rs->fetch_assoc();
//把关联数组的值，显示到form表单里面！
//var_dump($row);
require 'edit_html.php';
}
else
    {
     $username=$_POST['username'];
    $sex=$_POST['sex'];
    $message=$_POST['message'];
    $imgurl=$_POST['imgurl'];
    $sql="update t_message set username='$username',sex='$sex',message='$message',imgurl='$imgurl'"
            . "where id='$bbsid'";
    $rs=$db->query($sql);
    if($rs){
        echo "<script language='javascript' type='text/javascript'>";
        echo "alert('修改成功！');";
        echo "window.location.href='index.php';"; 
        echo "</script>";
        exit;

   }else{
      Header("Location:index.php");
   }
}









?>